<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改属性</title>
    <style>
        .box
        {
            width: 100px;
            height: 100px;
            font-size: 20px;
            color: red;
            background-color: blue;
        }
    </style>
</head>
<body>

    <div>
        我是div
    </div>

    <button class="add">添加样式</button>
    <button class="remove">删除样式</button>

    <script>
        //获取元素
        var divEl = document.querySelector("div");
        var addStyle = document.querySelector(".add");
        var removeStyle = document.querySelector(".remove");
        

        addStyle.onclick = function()
        {
            divEl.classList.add("box");
        }

        removeStyle.onclick = function()
        {
            divEl.classList.remove("box");
        }


    </script>
    
</body>
</html>